package tc.alert.tckejisoc.eum;

public enum AttackTypeEum {
    NONE("none", "非 Web 攻击"),
    SQL_INJECTION("sql_injection", "SQL 注入"),
    XSS("xss", "XSS"),
    CSRF("csrf", "CSRF"),
    SSRF("ssrf", "SSRF"),
    DOS("dos", "拒绝服务"),
    BACKDOOR("backdoor", "后门"),
    DESERIALIZATION("deserialization", "反序列化"),
    CODE_EXECUTION("code_execution", "代码执行"),
    CODE_INJECTION("code_injection", "代码注入"),
    COMMAND_INJECTION("command_injection", "命令注入"),
    FILE_UPLOAD("file_upload", "文件上传"),
    FILE_INCLUSION("file_inclusion", "文件包含"),
    REDIRECT("redirect", "重定向"),
    WEAK_PERMISSION("weak_permission", "权限不当"),
    INFO_LEAK("info_leak", "信息泄露"),
    UNAUTHORIZED_ACCESS("unauthorized_access", "未授权访问"),
    UNSAFE_CONFIG("unsafe_config", "不安全的配置"),
    XXE("xxe", "XXE"),
    XPATH_INJECTION("xpath_injection", "Xpath 注入"),
    LDAP_INJECTION("ldap_injection", "LDAP 注入"),
    DIRECTORY_TRAVERSAL("directory_traversal", "目录穿越"),
    SCANNER("scanner", "扫描器"),
    PERMISSION_BYPASS("permission_bypass", "水平权限绕过"),
    ACL_BYPASS("acl_bypass", "垂直权限绕过"),
    FILE_WRITE("file_write", "文件修改"),
    FILE_DOWNLOAD("file_download", "文件读取"),
    FILE_DELETION("file_deletion", "文件删除"),
    LOGIC_ERROR("logic_error", "逻辑错误"),
    CRLF_INJECTION("crlf_injection", "CRLF 注入"),
    SSTI("ssti", "模板注入"),
    CLICK_HIJACKING("click_hijacking", "点击劫持"),
    BUFFER_OVERFLOW("buffer_overflow", "缓冲区溢出"),
    INTEGER_OVERFLOW("integer_overflow", "整数溢出"),
    FORMAT_STRING("format_string", "格式化字符串"),
    RACE_CONDITION("race_condition", "条件竞争"),
    TIMEOUT("timeout", "超时"),
    THREAT_INTELLIGENCE("threat_intelligence", "威胁情报"),
    COOKIE_FALSIFICATION("cookie_falsification", "Cookie 篡改"),
    UNKNOWN("unknown", "未知");

    private final String typeCode;
    private final String chineseName;

    AttackTypeEum(String typeCode, String chineseName) {
        this.typeCode = typeCode;
        this.chineseName = chineseName;
    }

    public String getTypeCode() {
        return typeCode;
    }

    public String getChineseName() {
        return chineseName;
    }

    public static AttackTypeEum fromTypeCode(String typeCode) {
        for (AttackTypeEum type : values()) {
            if (type.typeCode.equalsIgnoreCase(typeCode)) {
                return type;
            }
        }
        return UNKNOWN;
    }
}